<html>
<head>
<link href="css/style.css" rel="stylesheet" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head>
<body>
<div id="container">
<div id="header"></div>
<div id="miniBtn"></div>
<div id="closeBtn"></div>
<div id="devBtn"></div>
<div id="title">开始下载</div>
<div id="progress_bar"><div id="progress"></div><div id="progressAni"></div></div>
</div>
<script>
closeBtn.onclick=function(){
	AlloyDesktop.closeHandler();
}
miniBtn.onclick=function(){
	AlloyDesktop.mini();
}
var contentLength=-1;
var byteCount=0;
var start=function(length){
	contentLength=length;
	if(contentLength!=-1&&id){
		clearInterval(id);
		id=0;
		progressAni.style.display='none';
	}
}
var setProgress=function(size){
	byteCount+=size;
	if(contentLength!=-1){
		progress.style.width=parseInt(186*byteCount/contentLength)+'px';
	}
}
devBtn.onclick=function(){
	AlloyDesktop.showDev();
}
var complete=function(){
	title.innerHTML='下载完成';
	if(contentLength==-1&&id){
		clearInterval(id);
		id=0;
		progressAni.style.display='none';
	}
	progress.style.width='186px';
	console.log('complete');
}
var i=0;
var id=setInterval(function(){++i;progressAni.style.left=i+'px';if(i>=130){i=5;}},10);
window.onload=function(){
	setTimeout(function(){
		AlloyDesktop.move(300,300);
		AlloyDesktop.setSize(230,100);
		AlloyDesktop.ready();
		setTimeout(function(){if(window['parentWindow'])AlloyDesktop.close(parentWindow);},0);
            //setTimeout(function () { AlloyDesktop.close(parentWindow); }, 0);
	},100);
}
AlloyDesktop.closeHandler=function(){
	AlloyDesktop.close();
}
header.onmousedown=function(){
	AlloyDesktop.drag();
}
header.onmouseup=function(){
	AlloyDesktop.stopDrag();

}
var sizeHandler=function(){
	container.style.height=e.detail.height-12+'px';
}
addEventListener('AlloyDesktopWindowResize',sizeHandler);
</script>
</body>
</html>